<?php 
namespace Home\Pay;

/*在线支付类*/
class JdPay{
	//v_amount.v_moneytype.v_oid.v_mid.v_url.v_key
  protected $v_amount;
  protected $v_oid; 
  protected $v_moneytype = 'CNY';
  protected $v_mid;
  protected $v_url;
  protected $v_key;
 public function __construct($v_oid,$v_amount)
 {
  $htis->v_oid = $v_oid;
  $htis->v_amount = $v_amount;
  $this->v_mid = C('C_MID');
  $this->v_url = C('C_URL');
  $this->v_key = C('C_KEY');
 }
 public function from()
 {
 	//商品编号
 	//订单编号
 	//订单总金额
 	//币种 
  $from = '<form action="https://pay3.chinabank.com.cn/PayGate" method="post">
		     <input type="hidden" name="v_mid" value="%s" />
		     <input type="hidden" name="v_oid" value="%s" />
		     <input type="hidden" name="v_amount" value="%s" />
		     <input type="hidden" name="v_moneytype" value="CNY" />
		     <input type="hidden" name="v_url" value="%s" />
		     <input type="hidden" name="v_md5info" value="%s" />
		    <input type="submit" value="支付"/>
         </form>';
return sprintf($from,$this->v_mid,$this->v_oid,$this->v_amount,$this->v_url,$this->sign());
 }
 public function sign()
 {
 	$sign = $this->v_amount.$this->v_moneytype.$this->v_oid.$this->v_mid.$this->v_url.$this->v_key;
 	return md5(strtoupper($sign));
 }

}